package servlet;

import bean.Result;
import biz.BizException;
import biz.userBiz;
import com.google.gson.Gson;
import dao.AddressDao;
import dao.QueryUserdao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet("/del_address.s")
public class DelAddressServlet extends HttpServlet {

    AddressDao dao=new AddressDao();
    QueryUserdao dao1=new QueryUserdao();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        final String username = req.getParameter("name");
        final String telphone = req.getParameter("telphone");
        final String site = req.getParameter("site");
        final HttpSession session = req.getSession();
        final String name = (String) session.getAttribute("user");
        final Map<String, Object> map = dao1.queryid(name);
        final Integer uid = (Integer) map.get("id");
        dao.del_address(username,telphone,uid,site);
        Result result;
        result =new Result(1,"移除成功",null);
        final String json = new Gson().toJson(result);
        resp.getWriter().append(json);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {


    }
}
